//
//  HomeTableViewCell2.m
//  GentlemanAnime
//
//  Created by dlios on 15-7-14.
//  Copyright (c) 2015年 lanou3g.com 蓝欧科技. All rights reserved.
//

#import "HomeTableViewCell2.h"
#import "DownloadSingletonTool.h"
#import "ImageViewController.h"
#import "AppDelegate.h"

@implementation HomeTableViewCell2
- (void)dealloc {
    [_titleLabel release];
    [_statusSwitch release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.font = [UIFont systemFontOfSize:15];
        self.titleLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:self.titleLabel];
        [_titleLabel release];
        
        self.statusSwitch = [[UISwitch alloc] init];
        [self.contentView addSubview:self.statusSwitch];
        [self.statusSwitch addTarget:self action:@selector(switchClick) forControlEvents:UIControlEventValueChanged];
        [_statusSwitch release];
        
    }
    return self;
}

- (void)switchClick {
    AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    UINavigationController *tempNaVC = tempAppDelegate.mainVC.tabBC.viewControllers[2];
    ImageViewController *imageVC = tempNaVC.viewControllers[0];
    if (self.statusSwitch.on) {
        [DownloadSingleton shareDownloadSingleton].fuli = YES;
        [imageVC.imageTableView reloadData];
        imageVC.titlelebel.text = @"特色麻吉";
    } else {
        [DownloadSingleton shareDownloadSingleton].fuli = NO;
        [imageVC.imageTableView reloadData];
        imageVC.titlelebel.text = @"漫图";
    }
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.titleLabel.frame = CGRectMake(15, 0, self.contentView.frame.size.width / 2, self.contentView.frame.size.height);
    self.statusSwitch.frame = CGRectMake(self.contentView.frame.size.width - 55, self.contentView.frame.size.height / 2 - 15.5, 30, 15);
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
